<template>
	<view>
		<view class="video-box">
			<view class="video-card">
				<view class="video-contentios">
					<MyVideo :videoUrl="videoUrl" class="video"></MyVideo>
					<!-- <image @click="showPopup(dataItem)" class="imgbox" src="@/static/play.png" mode="aspectFit"></image> -->
				</view>
				<!-- <view class="footer">
					<view class="title">
						<view class="title-txt">标题名称：</view>
						<view class="title-name">{{ dataItem.name }}</view>
					</view>
					<view class="time">发帖日期： {{ dataItem.createTime }}</view>
				</view> -->
			</view>
			<view class="group-content">
				<view class="video-title">
					<uni-icons type="list" :color="'#8d7e61'" size="20" class="icon" />
					视频列表：
				</view>
				<view class="video-content">
					<view class="video" v-for="item,i in dataList" :key="item.id" @click="videoChange(item)">
						<view :class="{ 'active': vedioId == item.vedioId }">{{ i+1 }}. {{ item.title }}</view>
						<view class="playing" v-if="vedioId == item.vedioId">
							正在播放
							<uni-icons type="videocam" :color="'#07aea1'" size="20" class="icon" />
						</view>
					</view>
				</view>
			</view>
			<!-- <view class="search-box">
				<view class="search">
					<hpy-form-select :dataList="dataList" text="title" name="vedioId"
						v-model="vedioId" @change="videoChange" hideArrow hideBorder
						style="width: 100%; padding-left: 20rpx;"></hpy-form-select>
					<uni-icons type="arrowdown" color="#cccccc"></uni-icons>
				</view>
			</view> -->
		</view>

		<!-- <view v-if="dataList.length == 0" class="facility-view-nodata">
			<image class="facility-view-blankimg" mode="widthFix" src="@/static/blank.png"></image>
			<view class="facility-view-nodata-line">
				暂无数据
			</view>
		</view> -->
	</view>
</template>

<script>
	import onlineClassApi from '@/api/socialized-servce/breed-aquatics/online-class/index.js'
	import MyVideo from "@/subPage1/components/myVideo/xcxVideo.vue"
	export default {
		components: {
			MyVideo
		},
		props: {
			vedioGroupId: {
				type: [Number, String],
				default: 1
			},
		},
		data() {
			return {
				dataItem: {},
				dataList: [],
				vedioId: '',
				videoUrl: ''
			}
		},
		mounted() {
			console.log(this.dataItem)
		},
		methods: {
			videoChange(row) {
				this.vedioId = row.vedioId
				this.videoUrl = row.addressUrl
				this.dataItem = row
				// console.log(this.vedioId)
				// let index = this.dataList.findIndex(el => {
				// 	return el.vedioId === this.vedioId
				// })
				// this.dataItem = this.dataList[index]
			},
			showPopup(row) {
				const params = {
					addressUrl: row.addressUrl,
					id: row.vedioId
				}
				const url = '/pages/popup/popup'
				this.$togo(url, params)
			},
			loadDataList(videoPage, param) {
				let params = { ...param }
				params.vedioId && (delete params.vedioId)
				onlineClassApi.queryByConditionVedio({
					vedioGroupId: this.vedioGroupId,
					...params,
					// auditStatus: 1
				}).then(res => {
					let list = res.data
					this.$emit('setVideoTotal', res.data.totalElements)
					this.dataList = list
					let index = res.data.findIndex(el => { return el.vedioId == param.vedioId })
					index == -1 && (index = 0)
					this.videoUrl = list[index].addressUrl
					this.dataItem = this.dataList[index]
					this.vedioId = this.dataList[index].vedioId
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.video-box {
		margin-top: 20rpx;

		.video-card {
			width: 100%;
			background-color: #fff;
			margin-bottom: 20rpx;
			padding: 20rpx;
			border-radius: 10rpx;
			box-sizing: border-box;
			
			.title {
				margin-top: 20rpx;

				.title-txt {
					display: inline-block;
					color: #0480fb;
					vertical-align: top;
				}

				.title-name {
					display: inline-block;
					width: calc(100% - 150rpx);
					overflow: hidden;
					text-overflow: ellipsis;
					white-space: nowrap;
				}
			}

			.video-content {
				::v-deep iframe {
					width: 100% !important;
					height: 320rpx !important;
				}
			}

			.video-contentios {
				width: 100%;
				height: 320rpx;
				background-color: #000000;
				position: relative;

				.imgbox {
					width: 150rpx;
					height: 150rpx;
					position: absolute;
					top: 50%;
					left: 50%;
					transform: translateX(-50%) translateY(-50%);
				}
			}
		}
		.group-content {
			padding: 0 20rpx;
			
			.icon {
				vertical-align: middle;
				margin-right: 10rpx;
			}

			.video-content {
				border: 1px solid #8d7e61;
				border-radius: 10rpx;
				
				.video {
					border-bottom: 1px solid #8d7e61;
					padding: 10rpx;
					position: relative;
					
					.active {
						width: calc(100% - 160rpx);
					}
					
					.playing {
						position: absolute;
						right: 0;
						top: 10rpx;
						color: #07aea1;
					}
					
					
					&:last-child {
						border-bottom: none;
					}
					
					&::before {
						display: inline-block;
						content: '';
						position: absolute;
					}
					
				}
			}
		}
		.search-box {
			display: flex;
			justify-content: center;
			align-items: center;
			padding: 15rpx 0;
			position: relative;

			.search {
				box-sizing: border-box;
				width: 97%;
				padding: 0rpx 20rpx;
				height: 80rpx;
				border-radius: 60rpx;
				background-color: rgba(255, 255, 255, 1);
				border: 1px solid rgba(0, 0, 0, 0.05);
				box-shadow: 0px 0px 6px rgba(0, 0, 0, 0.05);
				display: flex;
				justify-content: space-between;
				align-items: center;

				.search-content {
					display: flex;
					justify-content: space-evenly;
					align-items: center;
				}

				.clear-icon {
					position: absolute;
					top: 50%;
					right: 40rpx;
					transform: translateY(-50%);
					z-index: 200;
				}

				image {
					width: 50rpx;
					height: 50rpx;
				}

			}
		}
	}
</style>